import { request } from '@/utils/request';
// 文档详情页相关的接口
/**
 * 根据文档id查询文档详情
 * @returns {Promise<ApiRet>}
 */
const getDocDetailsByDocId = (docId) => {
  console.log('API调用参数:', { docId });
    return request({
      url: '/doc/getDocDetailsByDocId',
      method: 'GET',
      params: { docId }
    });
  };

/**
 * 根据文档id及权限获取文档分享码
 * @returns {Promise<ApiRet>}
 */
const getDocShareCode = (docId, docPermission) => {
    return request({
      url: '/doc/getDocShareCode',
      method: 'GET',
      params: {
        docId,
        docPermission
      }
    });
  };

/**
 * 校验文档分享码并获取文档详情
 * @returns {Promise<ApiRet>}
 */
const verifyDocShareCode = (shareCode) => {
  return request({
    url: '/doc/verifyDocShareCode',
    method: 'GET',
    params: {
        shareCode
    }
  });
};

/**
 * 新建、编辑保存文档详情信息
 * @returns {Promise<ApiRet>}
 */
const saveDocMessage = (data) => {
  return request({
      url: '/doc/saveDocMessage',
      method: 'POST',
      data
      });
  };
/**
 * 根据用户id获取用户名称——用于协同编辑时显示用户名
 * @returns {Promise<ApiRet>}
 */
const getUserNameById = (userId) => {
  return request({
    url: '/user/getUsernameByUserId',
    method: 'GET',
    params: { userId }
  });
};
export{
    getDocDetailsByDocId,
    getDocShareCode,
    verifyDocShareCode,
    saveDocMessage,
    getUserNameById
}